Skip to content

fix: handle tiny scientific notation#4

Merged
zombieJ merged 10 commits intomasterfrom
fix/ci-actions-cache-v4
Mar 13, 2026
Merged

fix: handle tiny scientific notation#4
zombieJ merged 10 commits intomasterfrom
fix/ci-actions-cache-v4

Conversation

@zombieJ
Copy link
Member

@zombieJ zombieJ commented Mar 13, 2026

Summary

  • upgrade all deprecated actions/cache@v2 usages in CI to actions/cache@v4
  • keep the workflow behavior unchanged while removing the deprecated cache action version

Testing

  • verified .github/workflows/main.yml no longer references actions/cache@v2

Summary by CodeRabbit

发布说明

  • 新功能

    • 改进了对极大/极小科学记数法数字的显示与解析,针对高精度和指数形式做出更稳健的处理。
  • 测试

    • 新增测试用例,验证非常小的科学计数(如 1e-307)及高精度指数情形的行为。
  • 杂务

    • 精简并重构了持续集成工作流,合并为单一测试流程以简化构建步骤。

@coderabbitai
Copy link

coderabbitai bot commented Mar 13, 2026

Warning

Rate limit exceeded

@zombieJ has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 4 minutes and 40 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: d1f2dd08-a985-4a7e-bf1c-ce2021ec2ee5

📥 Commits

Reviewing files that changed from the base of the PR and between 54bd664 and c572be5.

📒 Files selected for processing (4)
  • .gitignore
  • package.json
  • src/numberUtil.ts
  • tests/util.test.tsx

Walkthrough

将多任务 CI 工作流简化为单一委托外部工作流的 test job;引入 expandScientificNotation 并在科学记数法且精度 >100 时改变格式化分支;新增针对极小/极大科学记数法的单元测试并调整配置与依赖脚本。

Changes

Cohort / File(s) Summary
CI 工作流
​.github/workflows/main.yml
将多 job 的 CI 重构为单一 test job,改名并改为使用外部工作流 react-component/rc-test/.github/workflows/test.yml@main(继承 secrets);移除原有 setup/lint/compile/coverage 步骤与缓存细节。
数值处理核心
src/numberUtil.ts, src/NumberDecimal.ts
新增导出函数 expandScientificNotation;重写科学记数法精度计算与展开逻辑,num2str 在 precision>100 时使用展开逻辑;NumberDecimal.toString 在检测到 isE 且精度>100 时短路返回原始字符串。
测试
tests/util.test.tsx
新增针对非常小/非常大科学记数法的测试(例如 1e-307)及对 expandScientificNotation 的断言,覆盖 mockSupportBigInt 不同分支与格式化行为。
包与脚本
package.json
更新多个 devDependencies 与工具链(引入 rc-test@rc-component/np 等),大量脚本改写(testrc-test、新增 coverage、调整 deploy/compile 流程)。
配置与类型
.umirc.ts, tsconfig.json
将部分站点元数据移动到 themeConfig 中;在 tsconfig.json 中新增 typesinclude 配置以包含测试与 node 类型。

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Poem

🐰 我在草丛里算一算,数字跳着小小圈,

科学记数悄悄展开,零后秘密现真颜,
测试灯下轻声念,CI 换装路更简短,
胡萝卜香里数格式,代码旅程又一站。

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed PR标题『fix: handle tiny scientific notation』与主要变更高度相关,涵盖了src/numberUtil.ts中科学计数法处理的核心改进。

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/ci-actions-cache-v4
📝 Coding Plan
  • Generate coding plan for human review comments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@gemini-code-assist
Copy link

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly improves the precision and accuracy of number handling, particularly for very small or very large numbers expressed in scientific notation. It introduces a robust mechanism to expand scientific notation into full decimal strings, which is then integrated into the core number-to-string conversion logic. This ensures that numbers with extreme precision are correctly represented, preventing data loss or incorrect formatting in various scenarios.

Highlights

  • Scientific Notation Expansion: Introduced a new utility function expandScientificNotation to accurately convert numbers expressed in scientific notation (e.g., '1e-9') into their full decimal string representation.
  • High Precision Number Conversion: Enhanced the num2str function to utilize expandScientificNotation for numbers with extremely high precision (more than 100 decimal places) to prevent potential precision loss when converting to a fixed-point string.
  • NumberDecimal Class Update: Modified the NumberDecimal class's toString method to directly return the string representation of numbers in scientific notation if their precision exceeds 100, ensuring correct handling of such edge cases.
  • New Test Case for Precision: Added a dedicated test case to validate the correct parsing and string conversion of very small scientific notation values, specifically 1e-307, confirming the improved precision handling.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • src/NumberDecimal.ts
    • Imported the isE function for scientific notation detection.
    • Added a conditional check within the toString method to handle scientific notation numbers with precision greater than 100 by returning their direct string representation.
  • src/numberUtil.ts
    • Added a new function expandScientificNotation to convert scientific notation strings into their full decimal form.
    • Modified the num2str function to conditionally use expandScientificNotation for numbers whose precision exceeds 100.
  • tests/util.test.tsx
    • Added a new test case to verify the correct parsing and string conversion of 1e-307.
Ignored Files
  • Ignored by pattern: .github/workflows/** (1)
    • .github/workflows/main.yml
Activity
  • No human activity has been recorded on this pull request yet.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@zombieJ zombieJ changed the title ci: update actions/cache to v4 fix: handle tiny scientific notation Mar 13, 2026
@socket-security
Copy link

socket-security bot commented Mar 13, 2026

Warning

Review the following alerts detected in dependencies.

According to your organization's Security Policy, it is recommended to resolve "Warn" alerts. Learn more about Socket for GitHub.

Action Severity Alert  (click "▶" to expand/collapse)
Warn High
Obfuscated code: npm buffer-okam is 96.0% likely obfuscated

Confidence: 0.96

Location: Package overview

From: ?npm/buffer-okam@4.9.2

ℹ Read more on: This package | This alert | What is obfuscated code?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: Packages should not obfuscate their code. Consider not using packages with obfuscated code.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore npm/buffer-okam@4.9.2. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

View full report

@github-actions
Copy link

github-actions bot commented Mar 13, 2026

😭 Deploy PR Preview c572be5 failed. Build logs

🤖 By surge-preview

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces handling for very small numbers in scientific notation, primarily through a new expandScientificNotation function. While reviewing, I identified a critical bug in this new function that leads to incorrect expansion for numbers with a mantissa less than 1. I've provided a detailed comment with a suggested fix to address this issue. The other changes in the pull request appear to correctly integrate this new functionality.

Comment on lines +68 to +69
const digits = `${integer}${decimal}`.replace(/^0+/, '') || '0';
const decimalIndex = integer.length + exp;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

The calculation for decimalIndex is incorrect for numbers where the mantissa is less than 1 (e.g., 0.123e-5). Using integer.length doesn't work correctly because for numbers like 0.123, integer is 0 and its length is 1, which doesn't capture the true position of the significant digits. This results in an incorrect expansion. For instance, 0.123e-1 is incorrectly expanded to 0.123 instead of the correct 0.0123.

To fix this, the logic for decimalIndex needs to differentiate between numbers with an integer part greater than zero and those that are purely fractional.

Suggested change
const digits = `${integer}${decimal}`.replace(/^0+/, '') || '0';
const decimalIndex = integer.length + exp;
const digits = `${integer}${decimal}`.replace(/^0+/, '') || '0';
if (digits === '0') {
return '0';
}
let decimalIndex;
if (integer !== '0' || !unsignedMantissa.includes('.')) {
decimalIndex = integer.length + exp;
} else {
const leadingZeros = (decimal.match(/^0*/) || [''])[0].length;
decimalIndex = exp - leadingZeros;
}

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
tests/util.test.tsx (1)

66-70: 建议补充阈值边界断言,锁定 > 100 分支行为。

当前已覆盖 1e-307,建议再补 1e-100 / 1e-101(以及可选负号场景)以防后续修改影响阈值判定。

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/util.test.tsx` around lines 66 - 70, 在现有 getDecimal 测试里补充阈值边界用例以锁定 “>
100” 分支:添加对 '1e-100' 和 '1e-101'(以及可选的负数 '-1e-100' 和
'-1e-101')的断言,使用与现有用例相同的比较风格(参照 tinyScientificValue 和 mockSupportBigInt
的现有断言)以确保当指数跨越 100 时行为不变;定位 getDecimal、tinyScientificValue、mockSupportBigInt 并在
tests/util.test.tsx 中新增这些断言以覆盖边界并防止阈值回归。
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@tests/util.test.tsx`:
- Around line 66-70: 在现有 getDecimal 测试里补充阈值边界用例以锁定 “> 100” 分支:添加对 '1e-100' 和
'1e-101'(以及可选的负数 '-1e-100' 和 '-1e-101')的断言,使用与现有用例相同的比较风格(参照 tinyScientificValue
和 mockSupportBigInt 的现有断言)以确保当指数跨越 100 时行为不变;定位
getDecimal、tinyScientificValue、mockSupportBigInt 并在 tests/util.test.tsx
中新增这些断言以覆盖边界并防止阈值回归。

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 4fb4522e-647c-4127-b5e3-6c6ce62327c2

📥 Commits

Reviewing files that changed from the base of the PR and between 0665397 and 9642a11.

📒 Files selected for processing (4)
  • .github/workflows/main.yml
  • src/NumberDecimal.ts
  • src/numberUtil.ts
  • tests/util.test.tsx

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.github/workflows/main.yml:
- Around line 7-8: 不要将可复用工作流引用固定为 `@main` 并同时使用 secrets: inherit;把 uses:
react-component/rc-test/.github/workflows/test.yml@main 改为指向上游仓库的不可变 commit SHA
(例如 ...@<commit-sha>),并删除 secrets: inherit,然后通过上游工作流的 workflow_call 输入或显式
environment/with 参数传递仅需的单个 secrets(或在调用处从 repository secrets 显式注入),确保在调用处列出具体
secret 名称而不是继承全部,以减少供应链与权限风险。
- Line 3: 恢复 workflow 的分支过滤:不要使用无条件的 "on: [push, pull_request]",而是将触发器改回分别声明
push 和 pull_request 并限制 branches 为 master(使用 keys: on -> push -> branches:
[master] 和 on -> pull_request -> branches: [master]),以恢复原有 CI 触发范围。
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: e1890020-49be-4c93-80d7-bead4ce4e000

📥 Commits

Reviewing files that changed from the base of the PR and between 9642a11 and 80adb23.

📒 Files selected for processing (1)
  • .github/workflows/main.yml

branches: [master]
pull_request:
branches: [master]
on: [push, pull_request]
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

# 验证上一版 `.github/workflows/main.yml` 是否在 `on:` 下保留了分支过滤条件。
# 预期:如果旧文件里在 `push` / `pull_request` 下存在 `branches:`,
# 说明这次改动放宽了触发范围,需要把过滤条件补回。

prev="$(git log --format=%H -- .github/workflows/main.yml | sed -n '2p')"
if [ -z "$prev" ]; then
  echo "本地历史里没有找到 .github/workflows/main.yml 的上一版。" >&2
  exit 1
fi

echo "=== 上一版 workflow 头部 ($prev) ==="
git show "${prev}:.github/workflows/main.yml" | sed -n '1,40p'

echo
echo "=== 当前 workflow 头部 ==="
sed -n '1,40p' .github/workflows/main.yml

Repository: react-component/mini-decimal

Length of output: 1817


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# 检查当前工作区是否存在 .github/workflows/main.yml
if [ -f ".github/workflows/main.yml" ]; then
  echo "=== 当前 workflow on: 配置 (前 20 行) ==="
  head -20 .github/workflows/main.yml
  echo
fi

# 尝试查看 git 历史(如果存在)
if git rev-parse --git-dir > /dev/null 2>&1; then
  echo "=== Git 历史查询 ==="
  # 获取涉及该文件的最近 3 个提交
  git log --oneline -n 3 -- .github/workflows/main.yml 2>/dev/null || echo "无法访问 git 历史"
  echo
  
  # 尝试获取前一个版本
  prev_commit=$(git log --format=%H -- .github/workflows/main.yml 2>/dev/null | sed -n '2p')
  if [ -n "$prev_commit" ]; then
    echo "=== 前一版本 workflow on: 配置 ($prev_commit) ==="
    git show "${prev_commit}:.github/workflows/main.yml" 2>/dev/null | head -20 || echo "无法显示前一版本"
  fi
else
  echo "当前目录不是 git 仓库"
fi

Repository: react-component/mini-decimal

Length of output: 308


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "=== 查看 .github/workflows/main.yml 的完整 git 历史 ==="
git log --all --oneline -- .github/workflows/main.yml | head -10

echo
echo "=== 显示当前版本的完整内容 ==="
cat .github/workflows/main.yml

echo
echo "=== 尝试显示前一个版本 ==="
# 获取所有涉及该文件的提交
commits=$(git log --format=%H --all -- .github/workflows/main.yml)
commit_array=($commits)

if [ ${`#commit_array`[@]} -gt 1 ]; then
  echo "前一版本提交: ${commit_array[1]}"
  git show "${commit_array[1]}:.github/workflows/main.yml" 2>/dev/null || echo "无法显示"
else
  echo "只有一个提交,无法比较"
  # 尝试显示该提交中的变更
  if [ ${`#commit_array`[@]} -gt 0 ]; then
    echo "显示当前提交 ${commit_array[0]} 中对该文件的改动:"
    git show "${commit_array[0]}":".github/workflows/main.yml" 2>/dev/null || echo "无法显示"
  fi
fi

Repository: react-component/mini-decimal

Length of output: 3224


🏁 Script executed:

#!/bin/bash
# 显示应该的修复方案
echo "=== 应该恢复的配置 ==="
cat <<'EOF'
on:
  push:
    branches: [master]
  pull_request:
    branches: [master]
EOF

Repository: react-component/mini-decimal

Length of output: 161


需要恢复 workflow 的分支过滤条件。

Line 3 将触发器改成了无条件的 on: [push, pull_request],而原配置在 pushpull_request 上都限制了 branches: [master]。这扩大了 CI 触发范围,与 PR 目标中的"保持现有行为"不符。请将分支过滤条件恢复:

on:
  push:
    branches: [master]
  pull_request:
    branches: [master]
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/workflows/main.yml at line 3, 恢复 workflow 的分支过滤:不要使用无条件的 "on: [push,
pull_request]",而是将触发器改回分别声明 push 和 pull_request 并限制 branches 为 master(使用 keys:
on -> push -> branches: [master] 和 on -> pull_request -> branches:
[master]),以恢复原有 CI 触发范围。

Comment on lines +7 to +8
uses: react-component/rc-test/.github/workflows/test.yml@main
secrets: inherit
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

git ls-files | grep -E "\.github/workflows"

Repository: react-component/mini-decimal

Length of output: 128


🏁 Script executed:

cat -n .github/workflows/main.yml

Repository: react-component/mini-decimal

Length of output: 268


不要把继承 secrets 的复用工作流绑定到 @main

Line 7 引用的是外部仓库的 reusable workflow,Line 8 又继承了全部 secrets。@main 是可变引用,上游后续提交会直接改变这里执行的 CI 内容;和 secrets: inherit 组合后,供应链与最小权限风险都会被放大。建议固定到 commit SHA,并改成按 workflow_call 显式传递所需 secrets。

建议修改
-    uses: react-component/rc-test/.github/workflows/test.yml@main
+    uses: react-component/rc-test/.github/workflows/test.yml@<pinned-commit-sha>
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/workflows/main.yml around lines 7 - 8, 不要将可复用工作流引用固定为 `@main` 并同时使用
secrets: inherit;把 uses: react-component/rc-test/.github/workflows/test.yml@main
改为指向上游仓库的不可变 commit SHA (例如 ...@<commit-sha>),并删除 secrets: inherit,然后通过上游工作流的
workflow_call 输入或显式 environment/with 参数传递仅需的单个 secrets(或在调用处从 repository secrets
显式注入),确保在调用处列出具体 secret 名称而不是继承全部,以减少供应链与权限风险。

@codecov
Copy link

codecov bot commented Mar 13, 2026

Codecov Report

❌ Patch coverage is 85.29412% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 91.17%. Comparing base (0665397) to head (c572be5).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
src/numberUtil.ts 84.37% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master       #4      +/-   ##
==========================================
- Coverage   91.86%   91.17%   -0.69%     
==========================================
  Files           5        5              
  Lines         209      238      +29     
  Branches       56       70      +14     
==========================================
+ Hits          192      217      +25     
- Misses         17       21       +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@socket-security
Copy link

socket-security bot commented Mar 13, 2026

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (3)
tsconfig.json (1)

17-22: tests 目录的 include 模式可能遗漏了 .ts 文件

当前 include 配置中,tests 目录只包含了 *.tsx 文件,但测试文件也可能是纯 .ts 文件。建议添加 ./tests/**/*.ts 模式以确保完整覆盖。

♻️ 建议的修改
   "include": [
     "./src/**/*.ts",
     "./src/**/*.tsx",
     "./docs/**/*.tsx",
-    "./tests/**/*.tsx"
+    "./tests/**/*.tsx",
+    "./tests/**/*.ts"
   ]
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tsconfig.json` around lines 17 - 22, tsconfig.json’s "include" array
currently only matches "./tests/**/*.tsx", which misses plain .ts test files;
update the include array (the "include" entry in tsconfig.json) to also include
"./tests/**/*.ts" so all test files under the tests directory are covered.
package.json (1)

64-66: 建议更新 Node.js 最低版本要求

当前配置的 "node": ">=8.x" 与现代依赖不匹配。TypeScript 5.x 需要 Node.js 14.17+,@testing-library/react 16.x 需要更高版本。建议将最低版本更新为 Node.js 18.x 以确保兼容性。

♻️ 建议的修改
   "engines": {
-    "node": ">=8.x"
+    "node": ">=18.x"
   }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@package.json` around lines 64 - 66, The package.json "engines" field
currently pins "node": ">=8.x", which is incompatible with modern deps; update
the "engines" -> "node" entry to a current minimum (e.g., ">=18.x" or ">=18") to
match TypeScript 5.x and modern testing libs, and ensure CI/workflow configs and
any engine checks (e.g., in Dockerfiles or .nvmrc) are updated consistently to
Node 18 to avoid runtime/installation issues.
tests/util.test.tsx (1)

147-159: 建议补充更多边界测试用例

当前测试覆盖了负指数的情况,建议考虑添加以下边界用例以增强覆盖:

♻️ 建议添加的测试用例
   describe('scientific notation', () => {
     it('expands fractional mantissas correctly', () => {
       expect(expandScientificNotation('0.123e-1')).toEqual('0.0123');
       expect(expandScientificNotation('-0.123e-1')).toEqual('-0.0123');
       expect(expandScientificNotation('0.00123e2')).toEqual('0.123');
       expect(expandScientificNotation('0e5')).toEqual('0');
+      // 大正指数
+      expect(expandScientificNotation('1.5e3')).toEqual('1500');
+      expect(expandScientificNotation('1.23e2')).toEqual('123');
     });
 
     it('keeps num2str behavior correct for normalized numbers', () => {
       expect(num2str(1.23e-19)).toEqual(`0.${'0'.repeat(18)}123`);
       expect(num2str(-1.23e-20)).toEqual(`-0.${'0'.repeat(19)}123`);
+      // 正指数
+      expect(num2str(1.5e10)).toEqual('15000000000');
     });
   });
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/util.test.tsx` around lines 147 - 159, Add additional boundary tests
for expandScientificNotation and num2str to improve coverage: include exponent
zero (e.g., "1.23e0"), positive exponents that increase integer part (e.g.,
"1.23e3" and "0.00123e5"), very large positive and negative exponents, pure
integer mantissas (e.g., "123e-2"), and tiny values that should produce "0"
(e.g., "0e0" and extremely negative exponents) to ensure
expandScientificNotation and num2str handle zero, positive exponents, integer
mantissas, and extreme magnitudes correctly.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@package.json`:
- Around line 28-38: The package.json scripts deploy, now-build and
prepublishOnly reference a non-existent global binary "ut"; update those scripts
to either (A) install the correct devDependency that provides the "ut" binary
(add the package that actually exposes "ut" to devDependencies) and run npm
install, or (B) replace the "ut" invocations with the intended existing npm
script/command (for example use "npm run <script>" or the existing
"rc-test"/"dumi"/build commands) so the scripts succeed; specifically change the
"deploy", "now-build" and "prepublishOnly" script entries to use the correct
tool or add the missing devDependency that exports "ut".

In `@src/numberUtil.ts`:
- Around line 135-140: In NumberDecimal.add() and NumberDecimal.multi(), the
calls to number.toFixed(maxPrecision) must guard against precision > 100
(toFixed supports only 0–100); use getNumberPrecision(numStr) and if precision >
100 call expandScientificNotation(numStr) (same logic as in toString()) instead
of toFixed, otherwise call number.toFixed(precision); update both add() and
multi() to apply this check so they mirror the protection already present in
toString().

---

Nitpick comments:
In `@package.json`:
- Around line 64-66: The package.json "engines" field currently pins "node":
">=8.x", which is incompatible with modern deps; update the "engines" -> "node"
entry to a current minimum (e.g., ">=18.x" or ">=18") to match TypeScript 5.x
and modern testing libs, and ensure CI/workflow configs and any engine checks
(e.g., in Dockerfiles or .nvmrc) are updated consistently to Node 18 to avoid
runtime/installation issues.

In `@tests/util.test.tsx`:
- Around line 147-159: Add additional boundary tests for
expandScientificNotation and num2str to improve coverage: include exponent zero
(e.g., "1.23e0"), positive exponents that increase integer part (e.g., "1.23e3"
and "0.00123e5"), very large positive and negative exponents, pure integer
mantissas (e.g., "123e-2"), and tiny values that should produce "0" (e.g., "0e0"
and extremely negative exponents) to ensure expandScientificNotation and num2str
handle zero, positive exponents, integer mantissas, and extreme magnitudes
correctly.

In `@tsconfig.json`:
- Around line 17-22: tsconfig.json’s "include" array currently only matches
"./tests/**/*.tsx", which misses plain .ts test files; update the include array
(the "include" entry in tsconfig.json) to also include "./tests/**/*.ts" so all
test files under the tests directory are covered.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 0e0f1f77-1b04-4456-9689-26a209cc7c66

📥 Commits

Reviewing files that changed from the base of the PR and between 80adb23 and 54bd664.

📒 Files selected for processing (5)
  • .umirc.ts
  • package.json
  • src/numberUtil.ts
  • tests/util.test.tsx
  • tsconfig.json

@zombieJ zombieJ merged commit 73d3fe9 into master Mar 13, 2026
7 of 9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant